package {
	import flash.display.Sprite;
	
	import org.deft.tween.DEasing;
	import org.deft.tween.DTween;

	public class Demo1 extends Sprite {
		public function Demo1() {
			
			//只用一次的缓动，当动画完成后DTween对象会被回收
			//有三个方法DTween.to DTween.from DTween.fromTo 
			var b1:Sprite = new Ball(100, 100, 10 , 0xff0000);
			addChild(b1);
			
			DTween.to(b1, 5000, "x", 300, DEasing.easeOutQuadratic, function():void{trace("abc-def")});//x从当前位置到300
			DTween.from(b1, 5000, "y", 200, DEasing.easeOutQuadratic);
			DTween.fromTo(b1, 5000,"scaleX", 1, 2,DEasing.easeInElastic);
			DTween.fromTo(b1, 5000,"scaleY", 1, 2,DEasing.easeInElastic);
			
			
			//如果想保留DTween对象,可以声明DTween的实例
			var b2:Sprite = new Ball(40, 50, 10, 0x00ff00);
			addChild(b2);
			
			var t:DTween = new DTween(b2);
			t.modifyProp("x", b2.x, 300, 1000, DEasing.easeInBack);
			t.modifyProp("y", b2.y, 200, 1000, DEasing.easeInBack);
			t.modifyProp("scaleX", 1, 2, 5000, DEasing.easeInElastic);
			t.modifyProp("scaleY", 1, 2, 5000, DEasing.easeInElastic);
			t.start();
			
			//反复运动的动画
			var b3:Ball = new Ball(400,200, 10, 0x0000ff);
			addChild(b3);
			
			var t3:DTween = new DTween(b3, -1, true);
			t3.modifyProp("scaleX", 1, 2, 1000, DEasing.easeInSine);
			t3.modifyProp("scaleY", 1, 2, 1000, DEasing.easeInSine);
			t3.start();
			
		}
	}
}